package pokerantani.v2;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;

public class FeatureMaker {
	public static void main(String[] args) throws IOException {
		String fileName = args[0];
		File file = new File(fileName);
		if(!file.exists())
			throw new FileNotFoundException();
		else if(file.isFile())
			parseFile(file);
		else if(file.isDirectory())
			parseDirectory(file);
		else
			throw new RuntimeException("What the fuck is " + file + "?");
	}
	
	
	private static void parseDirectory(File directory) throws IOException {
		System.out.println("Scanning directory " + directory);
		File[] files = directory.listFiles(new FilenameFilter() {
			public boolean accept(File dir, String name) {
				return name.matches("Poker-Hand-.*\\.txt");
			}
		});
		for(File file : files)
			parseFile(file);
	}
	
	private static void parseFile(File file) throws IOException {
		System.out.println("------------ File: " + file.getName() + " -----------------");
		HandParser p = new HandParser(new BufferedReader(new FileReader(file)));
		System.out.println(p.hand.toString());
	}
}
